package cn.lsc.service.impl;

import cn.lsc.domain.Backlist;
import cn.lsc.domain.MessageSms;
import cn.lsc.dto.parDto;
import cn.lsc.enums.GlobaEnums;
import cn.lsc.mapper.BacklistMapper;
import cn.lsc.mapper.MessageSmsMapper;
import cn.lsc.result.JSONResult;
import cn.lsc.service.IMessageSmsService;
import cn.lsc.util.AssertUtil;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lsc
 * @since 2022-08-26
 */
@Service
public class MessageSmsServiceImpl extends ServiceImpl<MessageSmsMapper, MessageSms> implements IMessageSmsService {

    @Autowired
    private BacklistMapper backlistMapper;

    @Autowired
    private MessageSmsMapper messageSmsMapper;
    @Override
    public Object pullblack(parDto parDto) {
        String phone = parDto.getPhone();
        String text = parDto.getText();
        String ip = parDto.getIp();
        Long userId = parDto.getUserId();
        AssertUtil.isNotNull(phone, GlobaEnums.PHONE_IS_NULL_ERROR);
        backlistMapper.add(parDto);

        return null;
    }

    @Override
    public void del(Long id) {
        backlistMapper.del(id);
    }

    @Override
    public JSONResult pullBlack(parDto dto) {
        String ip = dto.getIp();
        String phone = dto.getPhone();
        Long userId = dto.getUserId();
        String text = dto.getText();
        backlistMapper.pullBlack(dto);
        return  JSONResult.success();
    }

    @Override
    public JSONResult findByphone(String phone) {
       /* Backlist byphone = backlistMapper.findByphone(phone);*/
        Backlist backlist= messageSmsMapper.findByphone(phone);
        return JSONResult.success(backlist);
    }
}
